package cn.swust.designpatternlearningplatform.event;

import org.springframework.context.ApplicationEvent;

import java.time.LocalDateTime;

public class TopicWrongEvent extends ApplicationEvent {

    public TopicWrongEvent(TopicWrongType source) {
        super(source);
    }

    public String getStudentNumber() {
        return ((TopicWrongType) getSource()).getStudentNumber();
    }

    public Integer getTopicId() {
        return ((TopicWrongType) getSource()).getTopicId();
    }

    public String getTopicType() {
        return ((TopicWrongType) getSource()).getTopicType();
    }

    public LocalDateTime getProblemTime() {
        return ((TopicWrongType) getSource()).getProblemTime();
    }

    public static class TopicWrongType {
        //学生学号
        private final String studentNumber;
        //题目id
        private final Integer topicId;
        //题目类型
        private final String topicType;
        //题目记录时间
        private final LocalDateTime problemTime;

        public TopicWrongType(String studentNumber, Integer topicId, String topicType, LocalDateTime problemTime) {
            this.studentNumber = studentNumber;
            this.topicId = topicId;
            this.topicType = topicType;
            this.problemTime = problemTime;
        }

        public String getStudentNumber() {
            return studentNumber;
        }

        public Integer getTopicId() {
            return topicId;
        }

        public String getTopicType() {
            return topicType;
        }

        public LocalDateTime getProblemTime() {
            return problemTime;
        }
    }

    /**
     * 创建TopicWrongEvent
     *
     * @param studentNumber
     * @param topicId
     * @param topicType
     * @return cn.swust.designpatternlearningplatform.event.TopicWrongEvent
     * @author Tang
     * @date 2023/9/26 10:43
     **/
    public static TopicWrongEvent build(String studentNumber, Integer topicId, String topicType,LocalDateTime problemTime) {
        TopicWrongType wrongType = new TopicWrongType(studentNumber, topicId, topicType, problemTime);
        return new TopicWrongEvent(wrongType);
    }
}


